import { request, oss } from '@/utils/request'

const paperApi = {
    // app
    AppInfo: '/managment/app/info', // 获取公众号信息
    RelatedPaper: '/managment/app/paper', // 关联问卷
    PostOnepaper: '/managment/app/onepaper', //关联单个问卷
    GetKeywords: '/managment/app/keywords', // 获取关键词
    PostKeywords: '/managment/app/keywords', // 修改关键词
    DelKeywords: '/managment/app/keyword', // 修改关键词
    SetReply: '/managment/app/replyMsg', // 设置关注自动回复消息
    AppReplyMsg: '/managment/app/replyMsg', // 获取关注自动回复消息

    // paper
    PaperList: '/managment/paper/list', // 获取问卷列表
    DelPaper: '/managment/paper/delete', // 删除问卷
    PaperCheck: '/managment/paper/check1', // 获取一个问卷的所有信息
    PaperCreate: '/managment/paper/create1', //创建 / 修改问卷
    PaperTitle: '/managment/paper/title', // 修改问卷标题
    PaperDefaultList: '/managment/paper/defaultList', // 获取题库

    // data
    AppPapersCount: '/managment/userpaper/count', // 公众号数据统计
    UserpaperGrowth:'/managment/userpaper/growth', //公众号净增数据

    // imageTemplate
    ImageTemplateCreate: '/managment/imageTemplate/create', // 上传用户新增的答案模版信息
    ImageTemplateList: '/managment/imageTemplate/list', // 获取分享的图片模版列表
    ImageTemplateDelete: '/managment/imageTemplate/delete', // 删除答案模版信息

    //oss
    AnswerImage: '/ostks/answerimage',

    //question bank
    PublicPaperList:'/managment/publicPaper/list',//获取题库列表
    PublicPaperCreate:'/managment/publicPaper/create',//添加问卷到题库
    PublicPaperDelete:'/managment/publicPaper/delete',//删除题库中的问卷
    // PublicPaperCheck:'/managment/publicPaper/check'
    PublicPaperCheck:'/managment/paper/check1'
}

// ----------------- app ----------------- //

// 获取公众号信息
export function fetchAppInfo(parameter) {
    return request({
        url: paperApi.AppInfo,
        method: 'get',
        data: parameter
    })
}
// 关联问卷
export function relatedPaper(parameter) {
    return request({
        url: paperApi.RelatedPaper,
        method: 'post',
        data: parameter
    })
}
// 关联单个问卷
export function PostOnepaper(parameter) {
    return request({
        url: paperApi.PostOnepaper,
        method: 'post',
        data: parameter
    })
}
// 设置关注自动回复消息
export function setReply(parameter) {
    return request({
        url: paperApi.SetReply,
        method: 'post',
        data: parameter
    })
}
// 获取关注自动回复消息
export function getReply(parameter) {
    return request({
        url: paperApi.AppReplyMsg,
        method: 'get',
        data: parameter,
    });
}

// 获取关键词
export function getKeywords(parameter) {
    return request({
        url: paperApi.GetKeywords,
        method: 'get',
        data: parameter,
        params: parameter
    });
}

// 修改关键词
export function postKeywords(parameter) {
    return request({
        url: paperApi.PostKeywords,
        method: 'post',
        data: parameter,
        params: parameter
    });
}

// 删除关键词
export function delKeywords(parameter) {
    const config = {
        url: paperApi.DelKeywords,
        method: 'delete',
        params: parameter
    }
    return request(config)
}

// ----------------- paper ----------------- //

// 获取问卷列表
export function fetchPaperList(parameter) {
    return request({
        url: paperApi.PaperList,
        method: 'get',
        data: parameter
    })
}
// 删除问卷
export function delPaper(parameter) {
    const config = {
        url: paperApi.DelPaper,
        method: 'delete',
        params: parameter
    }
    return request(config)
}
// 获取一个问卷的所有信息
export function getPaperInfo(parameter) {
    return request({
        url: paperApi.PaperCheck,
        method: 'get',
        // data: parameter,
        params: parameter
    });
}
//创建 / 修改问卷
export function createPaper(parameter) {
    return request({
        url: paperApi.PaperCreate,
        method: 'post',
        data: parameter,
    });
}
// 修改问卷标题
export function getPaperDefaultList(parameter) {
    return request({
        url: paperApi.PaperDefaultList,
        method: 'get',
        data: parameter,
    });
}

// ----------------- imageTemplate ----------------- //
// 上传用户新增的答案模版信息
export function postImageTemplate(parameter) {
    return request({
        url: paperApi.ImageTemplateCreate,
        method: 'post',
        data: parameter,
    });
}
// 获取分享的图片模版列表
export function getTmpls(parameter) {
    return request({
        url: paperApi.ImageTemplateList,
        method: 'get',
        data: parameter,
    });
}
// 删除答案模版信息
export function delTmpls(parameter) {
    return request({
        url: paperApi.ImageTemplateDelete,
        method: 'delete',
        params: parameter
    });
}


// ----------------- oss ----------------- //
export function getOssPolicy(parameter) {
    return oss({
        url: paperApi.AnswerImage,
        method: 'get',
        data: parameter
    });
}

// ----------------- data ----------------- //
// 公众号数据统计
export function AppPapersCount(parameter) {
    return request({
        url: paperApi.AppPapersCount,
        method: 'get',
        params: parameter,
    });
}
//公众号净增数据
export function postUserpaperGrowth(parameter) {
    return request({
        url: paperApi.UserpaperGrowth,
        method: 'get',
        params: parameter,
    });
}


// ----------------- question bank ----------------- //
//获取题库列表
export function getPublicPaperList(parameter) {
    return request({
        url: paperApi.PublicPaperList,
        method: 'get',
        params: parameter,
    });
}
//添加问卷到题库
export function postPublicPaperCreate(parameter) {
    return request({
        url: paperApi.PublicPaperCreate,
        method: 'post',
        data: parameter,
    });
}
//删除题库中的问卷PublicPaperDelete
export function delPublicPaperDelete(parameter) {
    return request({
        url: paperApi.PublicPaperList,
        method: 'delete',
        params: parameter,
    });
}
//编辑查看问卷
export function getPublicPaperCheck(parameter) {
    return request({
        url: paperApi.PublicPaperCheck,
        method: 'get',
        params: parameter,
    });
}


// PublicPaperCheck